using ExtendedMvc.Ajax;
using ExtendedMvc.Html;
//using ExtendedMvc.Behaviors;

namespace ExtendedMvc.Elements {
	/// <summary>
	/// Generate a validation message (text inside a span element).
	/// </summary>
	public class ResetLink : LinkBase<ResetLink> {
		private string _formId;
		private bool _disabled;

		public ResetLink(string content, string formId)
			: base(content, null) {
			SetAttribute(HtmlAttribute.Type, "reset");
			_formId = formId;
		}

		/// <summary>
		/// Set the 'value' attribute.
		/// </summary>
		/// <param name="value">The value for the attribute.</param>
		public virtual ResetLink Disabled(bool value = true) {
			_disabled = value;
			return this;
		}

		protected override void Prepare() {
			Link(_disabled ? "javascript: return false;" : string.Format(JavaScriptHelper.Reset, _formId));
			if (_disabled) SetAttribute(HtmlAttribute.Disabled, HtmlAttribute.Disabled);
			base.Prepare();
		}
	}
}